package jk.fox.common.payload.message;

import jk.fox.common.RpcDict;
import jk.fox.common.payload.request.RpcRequest;
import jk.fox.common.payload.response.RpcResponse;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

/**
 * serverExchange、transport 交互分发器
 * @author cuichao
 * @Description: Message
 * @Date: create in 2020/5/15 20:25
 */
@Getter
@Setter
public class Message {

    private RpcRequest request;
    private RpcResponse response;
    private RpcDict.MessageStatus status;
    private Map<String,Object> payload;



    public void payload(String key,Object value){
        if(payload == null){
            payload = new HashMap<>();
        }
        if(value == null || key == null){
            return;
        }
        payload.put(key,value);
    }

    public Object payload(String key){
        if(payload == null){
            return null;
        }
        return payload.get(key);
    }


}
